<?php
/**
 * The Inflector class
 */
class Inflector
{
	/**
	 * Convert underscore_words to camelCaps
	 * 
	 * @param string $name 
	 * @return string 
	 * @example camelize('underscore_words');
	 */
	static public function camelize($underscore_words)
	{
		$underscore_words = '_' . str_replace('_', ' ', strtolower($underscore_words));
		return ltrim(str_replace(' ', '', ucwords($underscore_words)), '_');
	}

	/**
	 * Convert camelCaps to underscore_words
	 * 
	 * @param string $name 
	 * @return string 
	 * @example underscore('camelCaps');
	 */
	static public function underscore($camelCaps)
	{
		return strtolower(preg_replace('/([a-z])([A-Z])/', "$1_$2", $camelCaps));
	}
}
